package cn.edu.sdjzu.xg2121.util;

import cn.edu.sdjzu.xg2121.domain.School;
import cn.edu.sdjzu.xg2121.domain.Teacher;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;

import java.util.List;


public class ControllerHelper {
    public static List<Condition> getConditions(JSONObject req_jsonObj){
        JSONArray conditionList_jsonArray=req_jsonObj.getJSONArray("conditionList");
        List<Condition> conditionList=null;
        if (conditionList_jsonArray!=null){
            conditionList=conditionList_jsonArray.toJavaList(Condition.class);
        }
        return conditionList;
    }

    public static  Pagination getPagination(JSONObject req_jsonObj){
        JSONObject pagination_jsonObj=req_jsonObj.getJSONObject("pagination");
        Pagination pagination=null;
        if (pagination_jsonObj!=null){
            pagination=pagination_jsonObj.toJavaObject(Pagination.class);
        }
        return pagination;
    }
    public  static  School getSchool(JSONObject req_jsonObj){
        JSONObject teacher_jsonObj=req_jsonObj.getJSONObject("teacher");
        School school=null;
        if (teacher_jsonObj!=null){
            school=teacher_jsonObj.toJavaObject(School.class);
        }
        return school;
    }
    public  static  int getId(JSONObject req_jsonObj){
        int school_jsonObj=req_jsonObj.getInteger("id");
        return school_jsonObj;
    }



}
